﻿<!--
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
-->
    
<controls:ChildWindow x:Class="System.Windows.Controls.Samples.StyledChildWindow"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
           xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
           Width="400" Height="300" 
           Title="StyledChildWindow">
    <controls:ChildWindow.Style>
        <Style TargetType="controls:ChildWindow">
            <Setter Property="IsTabStop" Value="false"/>
            <Setter Property="TabNavigation" Value="Cycle"/>
            <Setter Property="HorizontalAlignment" Value="Center"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
            <Setter Property="VerticalContentAlignment" Value="Stretch"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="controls:ChildWindow">
                        <Grid x:Name="Root">
                            <vsm:VisualStateManager.VisualStateGroups>
                                <vsm:VisualStateGroup x:Name="WindowStates">
                                    <vsm:VisualState x:Name="Open">
                                        <Storyboard>
                                            <ColorAnimationUsingKeyFrames BeginTime="0" Storyboard.TargetName="Overlay" Storyboard.TargetProperty="(Background).Color">
                                                <SplineColorKeyFrame KeyTime="0" Value="Pink"/>
                                            </ColorAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </vsm:VisualState>
                                    <vsm:VisualState x:Name="Opening">
                                        <Storyboard>
                                            <ColorAnimationUsingKeyFrames BeginTime="0" Storyboard.TargetName="Overlay" Storyboard.TargetProperty="(Background).Color">
                                                <SplineColorKeyFrame KeyTime="0" Value="Pink"/>
                                                <SplineColorKeyFrame KeyTime="00:00:00.2" Value="Pink"/>
                                            </ColorAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames BeginTime="0" Storyboard.TargetName="ContentRoot" Storyboard.TargetProperty="(RenderTransform).(Children)[0].ScaleX">
                                                <SplineDoubleKeyFrame KeyTime="0" Value="0"/>
                                                <SplineDoubleKeyFrame KeyTime="00:00:00.25" Value="0"/>
                                                <SplineDoubleKeyFrame KeyTime="00:00:00.4" Value="1"/>
                                                <SplineDoubleKeyFrame KeySpline="0,0,0.5,1" KeyTime="00:00:00.45" Value="1.05"/>
                                                <SplineDoubleKeyFrame KeyTime="00:00:00.55" Value="1"/>
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames BeginTime="0" Storyboard.TargetName="ContentRoot" Storyboard.TargetProperty="(RenderTransform).(Children)[0].ScaleY">
                                                <SplineDoubleKeyFrame KeyTime="0" Value="0"/>
                                                <SplineDoubleKeyFrame KeyTime="00:00:00.25" Value="0"/>
                                                <SplineDoubleKeyFrame KeyTime="00:00:00.4" Value="1"/>
                                                <SplineDoubleKeyFrame KeySpline="0,0,0.5,1" KeyTime="00:00:00.45" Value="1.05"/>
                                                <SplineDoubleKeyFrame KeyTime="00:00:00.55" Value="1"/>
                                            </DoubleAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </vsm:VisualState>
                                    <vsm:VisualState x:Name="Closing">
                                        <Storyboard>
                                            <ColorAnimationUsingKeyFrames BeginTime="0" Storyboard.TargetName="Overlay" Storyboard.TargetProperty="(Background).Color">
                                                <SplineColorKeyFrame KeyTime="0" Value="Pink"/>
                                                <SplineColorKeyFrame KeyTime="00:00:00.45" Value="Pink" KeySpline="0,0,0.5,1"/>
                                                <SplineColorKeyFrame KeyTime="00:00:00.5" Value="Pink"/>
                                            </ColorAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames BeginTime="0" Storyboard.TargetName="ContentRoot" Storyboard.TargetProperty="(RenderTransform).(Children)[0].ScaleX">
                                                <SplineDoubleKeyFrame KeyTime="00:00:00.2" Value="1"/>
                                                <SplineDoubleKeyFrame KeyTime="00:00:00.25" Value="1.05"/>
                                                <SplineDoubleKeyFrame KeyTime="00:00:00.45" Value="0"/>
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames BeginTime="0" Storyboard.TargetName="ContentRoot" Storyboard.TargetProperty="(RenderTransform).(Children)[0].ScaleY">
                                                <SplineDoubleKeyFrame KeyTime="00:00:00.2" Value="1"/>
                                                <SplineDoubleKeyFrame KeyTime="00:00:00.25" Value="1.05"/>
                                                <SplineDoubleKeyFrame KeyTime="00:00:00.45" Value="0"/>
                                            </DoubleAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </vsm:VisualState>
                                </vsm:VisualStateGroup>
                            </vsm:VisualStateManager.VisualStateGroups>
                            <Grid x:Name="Overlay" HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="0" Opacity="0.5">
                                <Grid.Background>
                                    <SolidColorBrush/>
                                </Grid.Background>
                            </Grid>
                            <Grid x:Name="ContentRoot" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}" RenderTransformOrigin="0.5,0.5" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}">
                                <Grid.RenderTransform>
                                    <TransformGroup>
                                        <ScaleTransform />
                                        <SkewTransform />
                                        <RotateTransform />
                                        <TranslateTransform />
                                    </TransformGroup>
                                </Grid.RenderTransform>
                                <Border BorderThickness="1" CornerRadius="2" BorderBrush="#14000000" Background="#14000000" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="-1"/>
                                <Border BorderThickness="1" CornerRadius="2.25" BorderBrush="#0F000000" Background="#0F000000" HorizontalAlignment="Stretch" Margin="-2" VerticalAlignment="Stretch"/>
                                <Border BorderThickness="1" CornerRadius="2.5" BorderBrush="#0C000000" Background="#0C000000" HorizontalAlignment="Stretch" Margin="-3" VerticalAlignment="Stretch"/>
                                <Border BorderThickness="1" CornerRadius="2.75" BorderBrush="#0A000000" Background="#0A000000" HorizontalAlignment="Stretch" Margin="-4" VerticalAlignment="Stretch"/>
                                <Border Background="#FFFFFFFF" BorderThickness="1" CornerRadius="2">
                                    <Border.BorderBrush>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                            <GradientStop Color="#FFA3AEB9" Offset="0"/>
                                            <GradientStop Color="#FF8399A9" Offset="0.375"/>
                                            <GradientStop Color="#FF718597" Offset="0.375"/>
                                            <GradientStop Color="#FF617584" Offset="1"/>
                                        </LinearGradientBrush>
                                    </Border.BorderBrush>
                                    <Border CornerRadius="1.5" Margin="1">
                                        <Border.Background>
                                            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                                <GradientStop Color="#FFE5E8EB" Offset="1"/>
                                                <GradientStop Color="#FFF6F8F9" Offset="0"/>
                                            </LinearGradientBrush>
                                        </Border.Background>
                                        <Grid>
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="Auto"/>
                                                <RowDefinition/>
                                            </Grid.RowDefinitions>
                                            <Border x:Name="Chrome" Height="24" Width="Auto" BorderBrush="#FFFFFFFF" BorderThickness="0,0,0,1">
                                                <Border.Background>
                                                    <LinearGradientBrush EndPoint="0.5,0.528" StartPoint="0.5,0">
                                                        <GradientStop Color="#FFE5E8EB" Offset="1"/>
                                                        <GradientStop Color="#FFFEFEFE" Offset="0"/>
                                                    </LinearGradientBrush>
                                                </Border.Background>
                                                <Grid Height="Auto" Width="Auto">
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition/>
                                                        <ColumnDefinition Width="30"/>
                                                    </Grid.ColumnDefinitions>
                                                    <ContentPresenter Content="{TemplateBinding Title}" 
                                                                  HorizontalAlignment="Stretch"
                                                                  VerticalAlignment="Center"
                                                                  Margin="6,0,6,0"/>
                                                </Grid>
                                            </Border>
                                            <Border Background="{TemplateBinding Background}" Margin="6" Grid.Row="1">
                                                <ContentPresenter x:Name="ContentPresenter" Content="{TemplateBinding Content}" 
                                                                  ContentTemplate="{TemplateBinding ContentTemplate}"
                                                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                                            </Border>
                                        </Grid>
                                    </Border>
                                </Border>
                            </Grid>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </controls:ChildWindow.Style>
    <Grid Margin="2">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <ContentControl Content="{Binding}" HorizontalAlignment="Center" VerticalAlignment="Center" />

        <Button Content="Cancel" Click="CancelButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,0,0" Grid.Row="1" />
        <Button Content="OK" Click="OKButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,79,0" Grid.Row="1" />
    </Grid>
</controls:ChildWindow>